const router=require('koa-router')();
const {emailBasedRateLimit}=require('../middlewares/rateLimit');

router.get('/',async (ctx,next)=>{
    console.log('csrf:',ctx.csrf);
    await ctx.render('reg',{
        title:[ctx.locals.name,'Reg'].join('-'),
        loginUser:ctx.session.loginUser,
        _csrf:ctx.csrf,
        success:ctx.flash.success,
        error:ctx.flash.error
    });
});

router.post('/',emailBasedRateLimit,async ctx=>{
   let {email}=ctx.request.body
   ctx.session.loginUser={email};
   ctx.body={email};
});
module.exports=router;